package com.xuecheng.learning.controller;


import com.xuecheng.base.model.PageResult;
import com.xuecheng.learning.model.dto.MyCourseTableParams;
import com.xuecheng.learning.model.dto.XcCourseTablesDTO;
import com.xuecheng.learning.model.po.XcCourseTables;
import com.xuecheng.learning.service.IXcCourseTablesService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 勾新杰
 * @since 2025-02-26
 */
@RestController
@RequiredArgsConstructor
@Api(tags = "课程表管理接口")
public class XcCourseTablesController {

    /**
     * 课表信息服务
     */
    private final IXcCourseTablesService courseTablesService;

    /**
     * 查询学习资格
     * @param courseId 课程id
     * @return 学习资格
     */
    @ApiOperation("查询学习资格")
    @PostMapping("/choosecourse/learnstatus/{courseId}")
    public XcCourseTablesDTO getLearningStatus(@PathVariable("courseId") Long courseId) {
        return courseTablesService.getLearningQualification(courseId);
    }

    /**
     * 我的课程表
     * @param params 查询条件
     * @return 分页结果
     */
    @ApiOperation("我的课程表")
    @GetMapping("/mycoursetable")
    public PageResult<XcCourseTables> myCourseTable(MyCourseTableParams params) {
        return courseTablesService.myCourseTable(params);
    }

    /**
     * 获取课程表
     * @param userId 用户id
     * @return 课程表
     */
    @ApiOperation("获取课程表")
    @GetMapping("/course-tables/{userId}")
    public List<XcCourseTables> getCourseTables(@PathVariable("userId") String userId){
        return courseTablesService.getCourseTables(userId);
    }
}
